package com.zx.system.block.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.Query;
import com.zx.validation.groups.StatusUpdate;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: 岗位请求参数 <br>
 * create: 2024-10-29 13:52
 * </p>
 *
 * @author zhou  xun
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PostParam implements Create, Update, StatusUpdate, Query {
    /**
     * 岗位ID
     */
    @ParameterValidation(index = 0, desc = "岗位ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~32")
    private String id;

    /**
     * 岗位编码
     */
    @ParameterValidation(index = 0, desc = "岗位编码", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~64")
    private String postCode;

    /**
     * 岗位名称
     */
    @ParameterValidation(index = 0, desc = "岗位名称", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~50")
    private String postName;

    /**
     * 显示顺序
     */
    @ParameterValidation(index = 0, desc = "显示顺序", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.NON_NEGATIVE_NUMBER})
    private Integer seqNo;

    /**
     * 岗位状态（0停用 1启用)
     */
    @ParameterValidation(index = 0, desc = "岗位状态", rules = {ValidateRulesEnum.NOT_NULL})
    private Integer status;

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 创建时间开始
     * 用于时间范围查询，当只提供开始时间时，查询大于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间开始", rules = {ValidateRulesEnum.NULL_DATE_TIME})
    private LocalDateTime createTimeStart;

    /**
     * 创建时间结束
     * 用于时间范围查询，当只提供结束时间时，查询小于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间结束", rules = {ValidateRulesEnum.NULL_DATE_TIME})
    private LocalDateTime createTimeEnd;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startUpdateTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endUpdateTime;

    /**
     * 备注
     */
    @ParameterValidation(index = 0, desc = "备注", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String remark;

    /**
     * 当前页码
     */
    private Long pageNum;

    /**
     * 每页显示条数
     */
    private Long pageSize;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("postCode", "postName", "seqNo", "status", "remark");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id", "postCode", "postName", "seqNo", "status", "remark");
    }

    @Override
    public Set<String> getQueryGroupFields() {
        return Set.of("postCode", "postName", "status", "createTimeStart", "createTimeEnd", "pageNum", "pageSize");
    }

    @Override
    public Set<String> getStatusUpdateGroupFields() {
        return Set.of("id", "status");
    }
}